IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'spTdocin_RetrieveAll')
	BEGIN
		PRINT 'Dropping Procedure spTdocin_RetrieveAll'
		DROP  Procedure  spTdocin_RetrieveAll
	END

GO

PRINT 'Creating Procedure spTdocin_RetrieveAll'
GO

CREATE Procedure spTdocin_RetrieveAll
	(
		@d_folder varchar(50) = null, 
		@d_loc varchar(50) = null, 
		@d_user varchar(50) = null, 
		@d_status varchar(50) = null, 
		@d_datetime DateTime = null
	)
AS
    /* 
    ------------------------------------------------------------------------------
    - Change History
    - --------------
    - Date          Description
    ------------------------------------------------------------------------------
    - 9/27/2007	Initial version created
    ------------------------------------------------------------------------------
    */
	
	SET NOCOUNT ON
	
	-- Retrieve the relevant records
	SELECT  *
	FROM	Tdocin
	
	WHERE	(@d_folder IS NULL OR Tdocin.d_folder LIKE @d_folder + '%')
	  AND	(@d_loc IS NULL OR Tdocin.d_loc LIKE @d_loc + '%')
	  AND	(@d_user IS NULL OR Tdocin.d_user LIKE @d_user + '%')
	  AND	(@d_status IS NULL OR Tdocin.d_status LIKE @d_status + '%')
	  AND	(@d_datetime IS NULL OR Tdocin.d_datetime = @d_datetime)

	-- Return to calling method
	RETURN
GO
